<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
<div class="box">
    
    <div class="heading">
      <h1><img src="view/image/category.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons">
						<a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a>
				</div>
       </div>
    <div class="content">
    <div id="tabs" class="htabs">
	<a href="#tab-general"><?php echo $tab_general; ?></a>
        <a href="#tab-data"><?php echo $tab_data; ?></a>
        <a href="#tab-related-news"><?php echo $tab_related_news; ?></a>
        <a href="#tab-comments"><?php echo $tab_comments; ?></a>
    </div>
						
				<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
				<?php if(!empty($check_news_id)){ ?>
					<div><input type="checkbox" name="ignore_date_modified" value="1"> <?php echo $text_ignore_date_modified; ?></div><br />
				<?php } ?>
								
						<div id="tab-general">
								<div id="languages" class="htabs">
										<?php foreach ($languages as $language) { ?>
												<a href="#language<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
										<?php } ?>
								</div>
								<?php foreach ($languages as $language) { ?>
										<div id="language<?php echo $language['language_id']; ?>">
										<table class="form">
												<tr>
												<td><span class="required">*</span> <?php echo $entry_title; ?></td>
												<td>
												<input name="news_description[<?php echo $language['language_id']; ?>][title]" size="100" value="<?php echo isset($news_description[$language['language_id']]) ? $news_description[$language['language_id']]['title'] : ''; ?>" />
												<?php if (isset($error_title[$language['language_id']])) { ?>
													<span class="error"><?php echo $error_title[$language['language_id']]; ?></span>
												<?php } ?>
												</td>
												</tr>
												<tr>
												<td><span class="required">*</span> <?php echo $entry_description; ?></td>
												<td><textarea name="news_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($news_description[$language['language_id']]) ? $news_description[$language['language_id']]['description'] : ''; ?></textarea>
												<?php if (isset($error_description[$language['language_id']])) { ?>
              								<span class="error"><?php echo $error_description[$language['language_id']]; ?></span>
              								<?php } ?>
              								</td>
          									</tr>
          									<tr>
            								<td><span class="required">*</span> <?php echo $entry_short_description; ?></td>
            								<td><textarea name="news_description[<?php echo $language['language_id']; ?>][short_description]" cols="80" rows="5"><?php echo isset($news_description[$language['language_id']]) ? $news_description[$language['language_id']]['short_description'] : ''; ?></textarea>
												</td>
          									</tr>     
          									<tr>
            								<td><?php echo $entry_meta_description; ?></td>
            								<td><textarea name="news_description[<?php echo $language['language_id']; ?>][meta_description]" cols="80" rows="3"><?php echo isset($news_description[$language['language_id']]) ? $news_description[$language['language_id']]['meta_description'] : ''; ?></textarea>
												</td>
          									</tr>   
          									<tr>
            								<td><?php echo $entry_meta_keyword; ?></td>
            								<td><textarea name="news_description[<?php echo $language['language_id']; ?>][meta_keyword]" cols="80" rows="3"><?php echo isset($news_description[$language['language_id']]) ? $news_description[$language['language_id']]['meta_keyword'] : ''; ?></textarea>
												</td>
          									</tr>    									
        								</table>
                              </div>
	                    <?php } ?>
	  					</div>
	  <div id="tab-data">
      <table class="form">
            <tr>
              <td><?php echo $entry_category; ?></td>
              <td><div class="scrollbox">
                  <?php $class = 'odd'; ?>
                  <?php foreach ($categories as $category) { ?>
                  <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                  <div class="<?php echo $class; ?>">
                    <?php if (in_array($category['news_category_id'], $news_category)) { ?>
                    <input type="checkbox" name="news_category[]" value="<?php echo $category['news_category_id']; ?>" checked="checked" />
                    <?php echo $category['name']; ?>
                    <?php } else { ?>
                    <input type="checkbox" name="news_category[]" value="<?php echo $category['news_category_id']; ?>" />
                    <?php echo $category['name']; ?>
                    <?php } ?>
                  </div>
                  <?php } ?>
                </div>
                <a onclick="$(this).parent().find(':checkbox').attr('checked', true);"><?php echo $text_select_all; ?></a> / <a onclick="$(this).parent().find(':checkbox').attr('checked', false);"><?php echo $text_unselect_all; ?></a></td>
            </tr>
        <tr>
            								<td><?php echo $entry_image; ?></td>
            								<td valign="top"><div class="image"><img src="<?php echo $image; ?>" alt="" id="thumb" />
                <input type="hidden" name="image" value="<?php echo $image; ?>" id="image" />
                <br /><a onclick="image_upload('image', 'thumb');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb').attr('src', '<?php echo $no_image; ?>'); $('#image').attr('value', '');"><?php echo $text_clear; ?></a></div></td>
          									</tr>
        <tr>
          <td><?php echo $entry_store; ?></td>
          <td><div class="scrollbox">
              <?php $class = 'even'; ?>
              <div class="<?php echo $class; ?>">
                <?php if (in_array(0, $news_store)) { ?>
                <input type="checkbox" name="news_store[]" value="0" checked="checked" />
                <?php echo $text_default; ?>
                <?php } else { ?>
                <input type="checkbox" name="news_store[]" value="0" />
                <?php echo $text_default; ?>
                <?php } ?>
              </div>
              <?php foreach ($stores as $store) { ?>
              <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
              <div class="<?php echo $class; ?>">
                <?php if (in_array($store['store_id'], $news_store)) { ?>
                <input type="checkbox" name="news_store[]" value="<?php echo $store['store_id']; ?>" checked="checked" />
                <?php echo $store['name']; ?>
                <?php } else { ?>
                <input type="checkbox" name="news_store[]" value="<?php echo $store['store_id']; ?>" />
                <?php echo $store['name']; ?>
                <?php } ?>
              </div>
              <?php } ?>
            </div></td>
        </tr>
        <tr>
          <td><?php echo $entry_keyword; ?></td>
          <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td>
        </tr>
        <tr>
            <td><?php echo $entry_allow_comment; ?></td>
            <td><select name="allow_comment">
                <?php if ($allow_comment) { ?>
                <option value="1" selected="selected"><?php echo $text_yes; ?></option>
                <option value="0"><?php echo $text_no; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_yes; ?></option>
                <option value="0" selected="selected"><?php echo $text_no; ?></option>
                <?php } ?>
              </select></td>
          </tr>
          <tr>
            <td><?php echo $entry_comment_permission; ?></td>
            <td><select name="comment_permission">
                <?php if ($comment_permission == 'all_user') { ?>
                <option value="all_user" selected="selected"><?php echo $text_all_user; ?></option>
                <option value="member_only"><?php echo $text_member_only; ?></option>
                <?php } elseif($comment_permission == 'member_only') { ?>
                <option value="all_user"><?php echo $text_all_user; ?></option>
                <option value="member_only" selected="selected"><?php echo $text_member_only; ?></option>
                <?php }else{ ?>
                <option value="all_user"><?php echo $text_all_user; ?></option>
                <option value="member_only"><?php echo $text_member_only; ?></option>
                <?php } ?>
              </select></td>
          </tr>
          <tr>
            <td><?php echo $entry_comment_need_approval; ?></td>
            <td><select name="comment_need_approval">
                <?php if ($comment_need_approval) { ?>
                <option value="1" selected="selected"><?php echo $text_yes; ?></option>
                <option value="0"><?php echo $text_no; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_yes; ?></option>
                <option value="0" selected="selected"><?php echo $text_no; ?></option>
                <?php } ?>
              </select></td>
          </tr>
		<tr>
            <td><?php echo $entry_status; ?></td>
            <td><select name="status">
                <?php if ($status) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select></td>
          </tr>
        <tr>
          <td><?php echo $entry_sort_order; ?></td>
          <td><input name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
        </tr>
      </table>
     </div>
     <div id="tab-related-news">
     	<table class="form">
        <tr>
          <td><div class="scrollbox">
                <?php $class = 'odd'; ?>
                <?php foreach ($newss as $news) { ?>
                <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                <div class="<?php echo $class; ?>">
                  <?php if (in_array($news['news_id'], $related_news)) { ?>
                  <input type="checkbox" name="related_news[]" value="<?php echo $news['news_id']; ?>" checked="checked" />
                  <?php echo $news['title']; ?>
                  <?php } else { ?>
                  <input type="checkbox" name="related_news[]" value="<?php echo $news['news_id']; ?>" />
                  <?php echo $news['title']; ?>
                  <?php } ?>
                </div>
                <?php } ?>
              </div></td>
        </tr>
      </table>
     </div>
     <div id="tab-comments">
     <?php echo $entry_with_selected; ?>
      <select name="with_selected">
            <option value="">---<?php echo $text_please_select; ?>---</option>
            <option value="approve"><?php echo $text_approve; ?></option>
            <option value="unapprove"><?php echo $text_unapprove; ?></option>
            <option value="delete"><?php echo $text_delete; ?></option>
      </select><br /><br />
     <table class="list">
     		<thead>
     			<tr>
            <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
            <td class="left"><?php echo $column_name; ?></td>
            <td class="left"><?php echo $column_email; ?></td>
            <td class="left"><?php echo $column_date; ?></td>
            <td class="left"><?php echo $column_comment; ?></td>
            <td class="left"><?php echo $column_status; ?></td>
          </tr>
     		</thead>
     		<tbody>
     		<?php if ($comments) { ?>
     		<?php foreach ($comments as $comment) { ?>
     		<tr>
            <td style="text-align: center;"><?php if ($comment['selected']) { ?>
              <input type="checkbox" name="selected[]" value="<?php echo $comment['news_comment_id']; ?>" checked="checked" />
              <?php } else { ?>
              <input type="checkbox" name="selected[]" value="<?php echo $comment['news_comment_id']; ?>" />
              <?php } ?></td>
            <td class="left"><?php echo $comment['name']; ?></td>
            <td class="left"><?php echo $comment['email']; ?></td>
            <td class="left"><?php echo $comment['date_added']; ?></td>
            <td class="left"><?php echo $comment['comment']; ?></td>
            <td class="left"><?php if($comment['status'] == '1'){ ?><span style="color: Green;"><?php echo $text_approved; ?></span><?php }else{ ?><span style="color: Red;"><?php echo $text_unapproved; ?></span><?php } ?></td>
          </tr>
     		<?php } ?>
     		<?php }else{ ?>
     		<tr>
            <td class="center" colspan="6"><?php echo $text_no_comments; ?></td>
          </tr>
     		<?php } ?>
     		</tbody>
     </table>
     </div>
    </form>
  </div>
</div>
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script>
<script type="text/javascript"><!--
<?php foreach ($languages as $language) { ?>
CKEDITOR.replace('description<?php echo $language['language_id']; ?>', {
	filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
<?php } ?>
//--></script>
<script type="text/javascript"><!--
function image_upload(field, thumb) {
	$('#dialog').remove();
	
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	
	$('#dialog').dialog({
		title: '<?php echo $text_image_manager; ?>',
		close: function (event, ui) {
			if ($('#' + field).attr('value')) {
				$.ajax({
					url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).val()),
					dataType: 'text',
					success: function(data) {
						$('#' + thumb).replaceWith('<img src="' + data + '" alt="" id="' + thumb + '" />');
					}
				});
			}
		},	
		bgiframe: false,
		width: 800,
		height: 400,
		resizable: false,
		modal: false
	});
};
//--></script> 
<script type="text/javascript"><!--
$('#tabs a').tabs(); 
$('#languages a').tabs();
//--></script> 
<?php echo $footer; ?>